<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
 <head>
  <meta http-equiv="content-type" content="text/html; charset=UTF-8">
  <title>返回最后一个PCRE正则执行产生的错误代码</title>
 </head>
 <body class="docs"><div id="layout">
  <div id="layout-content"><div id="function.preg-last-error" class="refentry">
 <div class="refnamediv">
  <h1 class="refname">preg_last_error</h1>
  <p class="verinfo">(PHP 5 &gt;= 5.2.0, PHP 7)</p><p class="refpurpose"><span class="refname">preg_last_error</span> &mdash; <span class="dc-title">返回最后一个PCRE正则执行产生的错误代码</span></p>

 </div>

 <div class="refsect1 description" id="refsect1-function.preg-last-error-description">
  <h3 class="title">说明</h3>
  <div class="methodsynopsis dc-description">
   <span class="methodname"><strong>preg_last_error</strong></span>
    ( <span class="methodparam">void</span>
   ) : <span class="type">int</span></div>

  <p class="para rdfs-comment">
   返回最后一次PCRE正则执行的错误代码。
  </p>
  <p class="para">
   <div class="example" id="example-5858">
    <p><strong>Example #1 <span class="function"><strong>preg_last_error()</strong></span> 示例</strong></p>
    <div class="example-contents">
<div class="phpcode"><pre><span style="color: #000000">
<span style="color: #0000BB">&lt;?php<br /><br />preg_match</span><span style="color: #007700">(</span><span style="color: #DD0000">'/(?:\D+|&lt;\d+&gt;)*[!?]/'</span><span style="color: #007700">,&nbsp;</span><span style="color: #DD0000">'foobar&nbsp;foobar&nbsp;foobar'</span><span style="color: #007700">);<br /><br />if&nbsp;(</span><span style="color: #0000BB">preg_last_error</span><span style="color: #007700">()&nbsp;==&nbsp;</span><span style="color: #0000BB">PREG_BACKTRACK_LIMIT_ERROR</span><span style="color: #007700">)&nbsp;{<br />&nbsp;&nbsp;&nbsp;&nbsp;print&nbsp;</span><span style="color: #DD0000">'Backtrack&nbsp;limit&nbsp;was&nbsp;exhausted!'</span><span style="color: #007700">;<br />}<br /><br /></span><span style="color: #0000BB">?&gt;</span>
</span>
</pre></div>
    </div>

    <div class="example-contents"><p>以上例程会输出：</p></div>
    <div class="example-contents screen">
<div class="cdata"><pre>
Backtrack limit was exhausted!
</pre></div>
    </div>
   </div>
  </p>
 </div>

  
 <div class="refsect1 returnvalues" id="refsect1-function.preg-last-error-returnvalues">
  <h3 class="title">返回值</h3>
  <p class="para">
   返回下面常量中的一个(<a href="pcre.constants.html" class="link">查看它们自身的解释</a>):
   <ul class="simplelist">
    <li class="member"><strong><code>PREG_NO_ERROR</code></strong></li>
    <li class="member"><strong><code>PREG_INTERNAL_ERROR</code></strong></li>
    <li class="member"><strong><code>PREG_BACKTRACK_LIMIT_ERROR</code></strong> （参见 <a href="pcre.configuration.html#ini.pcre.backtrack-limit" class="link">pcre.backtrack_limit</a>）</li>
    <li class="member"><strong><code>PREG_RECURSION_LIMIT_ERROR</code></strong> （参见 <a href="pcre.configuration.html#ini.pcre.recursion-limit" class="link">pcre.recursion_limit</a>）</li>
    <li class="member"><strong><code>PREG_BAD_UTF8_ERROR</code></strong></li>
    <li class="member"><strong><code>PREG_BAD_UTF8_OFFSET_ERROR</code></strong> （自 PHP 5.3.0 起）</li>
        <li class="member"><strong><code>PREG_JIT_STACKLIMIT_ERROR</code></strong> (自 PHP 7.0.0 起)</li>
   </ul>
  </p>
 </div>


</div></div></div></body></html>